//
// Created by wujehy on 2020/7/8.
//

#include <sstream>
#include "MySQLCpp/Exception.h"
#include "mysql/mysql.h"

using namespace GeeJoan::MySQL;

const char *Exception::getErrorStr() const noexcept
{
    if (current_hander != nullptr)
    {
        return mysql_error( current_hander );
    } else
    {
        return "undefine error ... ";
    }
}

Exception::Exception(const char *aErrorMessage, int ret) : std::runtime_error( aErrorMessage ),
                                                           mErrcode( ret ), mExtendedErrcode( -1 )
{

}

Exception::Exception(MYSQL *hander, int ret) :
        current_hander( hander ),
        mErrcode( ret ),
        mExtendedErrcode( mysql_errno( hander )),
        std::runtime_error( mysql_error( hander ))
{
}

Exception::Exception(MYSQL *hander) :
        current_hander( hander ), mErrcode( -1 ),
        mExtendedErrcode( mysql_errno( hander )),
        std::runtime_error( mysql_error( hander ))
{
}


